export function formatTimeDifference(timestamp) {
    const now = Date.now(); // 当前时间的时间戳
    const diff = now - timestamp; // 时间差（单位：毫秒）

    const oneMinute = 60 * 1000; // 1分钟的毫秒数
    const oneHour = 60 * oneMinute; // 1小时的毫秒数
    const oneDay = 24 * oneHour; // 1天的毫秒数
    const oneMonth = 30 * oneDay; // 1个月的毫秒数（这里假设1个月为30天）

    if (diff < oneMinute) {
        return "1分钟";
    } else if (diff < oneHour) {
        return `${Math.floor(diff / oneMinute)}分钟`;
    } else if (diff < oneDay) {
        return `${Math.floor(diff / oneHour)}小时`;
    } else if (diff < oneMonth) {
        return `${Math.floor(diff / oneDay)}天`;
    } else if (diff < 12 * oneMonth) {
        return `${Math.floor(diff / oneMonth)}月`;
    } else {
        return null;
    }
}

export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误将返回首页",
		showCancel:false,
		success:(res) => {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}